IF EXISTS (SELECT * FROM sysobjects WHERE type = 'V' AND name = 'VW_PaymentFetch')
	BEGIN
		DROP  View VW_PaymentFetch
	END
GO

CREATE View VW_PaymentFetch AS

SELECT
	p.PaymentId, p.AccountId, p.TypeFlag, p.Amount,
	p.Reference, p.PaymentDate, p.CreateDate, p.UpdateDate,
	a.Code AS AccountCode, a.Title AS AccountTitle
FROM Payments AS p
	INNER JOIN Accounts AS a ON a.AccountId = p.AccountId

GO